<!-- <template>
	<view style="height: 800px;">
		<iframe id="mapPage" width="100%" height="100%" frameborder=0
			src="https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=KJKBZ-PRNK2-S4HUQ-CF4BG-MS6HT-5HBJA&referer=惠吃外卖PLUS">
		</iframe>
	</view>
</template> -->
<template>
	<view>
		<web-view
			src="https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=KJKBZ-PRNK2-S4HUQ-CF4BG-MS6HT-5HBJA&referer=惠吃外卖PLUS"
			@message="bindmessage"></web-view>
	</view>
</template>
<script>
	// #ifdef H5
	window.addEventListener('message', function(event) {
		// 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
		var loc = event.data;
		console.log(event);
		////防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
		if (loc && loc.module == 'locationPicker') {
			//alert(loc.poiname);
			console.log(loc);
			var pages = getCurrentPages(),
				prevPage = null;
			if (pages.length > 1) {
				prevPage = pages[pages.length - 2];
				uni.setStorageSync('longitude', loc.latlng.lng);
				uni.setStorageSync('latitude', loc.latlng.lat);
				uni.setStorageSync('address', loc.poiname);
				prevPage.is_map = true;

				uni.navigateBack({
					delta: 0
				});
			}
		}
	});
	// #endif
	export default {
		data() {
			return {

			}
		},
		methods: {
			bindmessage(event) {
				// 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
				var loc = event.data;
				console.log(event);
				////防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
				if (loc && loc.module == 'locationPicker') {
					//alert(loc.poiname);
					console.log(loc);
					var pages = getCurrentPages(),
						prevPage = null;
					if (pages.length > 1) {
						prevPage = pages[pages.length - 2];
						uni.setStorageSync('longitude', loc.latlng.lng);
						uni.setStorageSync('latitude', loc.latlng.lat);
						uni.setStorageSync('address', loc.poiname);
						prevPage.is_map = true;

						uni.navigateBack({
							delta: 0
						});
					}
				}
			}
		}
	}
</script>

<style>

</style>